package com.daily.DailyStudy.设计模式.观察者模式;


import java.util.ArrayList;
import java.util.List;

public class SubjectImpl implements Subject{

    private List<Observer> observerList = new ArrayList<>();

    @Override
    public void attach(Observer observer) {
        observerList.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        observerList.remove(observer);
    }

    @Override
    public void notifyChanged() {
        for(Observer observer : observerList){
            observer.update();
        }
    }
}
